package com.example.test_20211014;

import java.lang.reflect.Field;

/**
 * @program: demo
 * @description: 测试类
 * @author: liulei
 * @create: 2021-10-14 15:57
 **/
public class Test {

    private String name;

    private Integer age = 2;


    public void test1(){
        System.out.println("1111111");
    }

    public void test2(){
        System.out.println("222222222222");
    }


    public static void main(String[] args) {
        Class<Test> testClass = Test.class;
        try {
            Object test = new Object();
            Field[] declaredFields = testClass.getDeclaredFields();
            for (int i = 0; i < declaredFields.length; i++) {
                Field declaredField = declaredFields[i];
                String name1 = declaredField.getName();
                System.out.println(name1);
                Object o = declaredField.get(test);
                System.out.println(o);
            }


        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(testClass);
    }
}
